package com.example.statistics.ui.port

import android.os.Bundle
import com.example.statistics.R
import com.example.statistics.bean.ColdStorageBean
import com.example.statistics.common.BaseLoadingListActivity
import com.example.statistics.net.UrlConfig
import com.example.statistics.utils.Constants
import com.example.statistics.utils.activityForResult
import com.jhj.slimadapter.SlimAdapter
import com.jhj.slimadapter.holder.ViewInjector

/**
 * 港口冷库列表
 */
class StorageListActivity : BaseLoadingListActivity<ColdStorageBean>() {

    override val title: String
        get() = "港口冷库"
    override val url: String
        get() = UrlConfig.PURCHASE_STORAGE_LIST
    override val itemLayoutRes: Int
        get() = R.layout.list_item_common_display

    override fun itemViewConvert(adapter: SlimAdapter, injector: ViewInjector, bean: ColdStorageBean, position: Int) {
        injector.text(R.id.tv_title, bean.city + bean.storage)
            .text(R.id.tv_subtitle, bean.position)
            .text(R.id.tv_status, bean.price.toString())
            .clicked {
                activityForResult<StorageAddActivity>(Constants.DATA to bean) {
                    refresh()
                }
            }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        topBarRightImage {
            activityForResult<StorageAddActivity>() {
                refresh()
            }
        }
    }


}